package limitStream;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

public class LimitDemo01 {
    public static void main(String[] args) {
        //limit是截取第n个元素
        List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9);
        Stream<Integer> limit1 = list.stream().limit(2);
        Stream<Integer> limit2 = list.stream().limit(6);
        System.out.println("----------------截取第2个---------------");
        limit1.forEach(System.out::println);
        System.out.println("-----------------截取6个---------------------");
        limit2.forEach(System.out::println);
    }
}
